import type { StoryObj, Meta } from '@storybook/react'
import Button from './button'
import { fn } from '@storybook/test'
import { Space } from 'antd'

// 定义组件的元数据
const buttonMeta = {
  title: '狗狗组件/Button',
  component: Button,
  tags: ['autodocs'], // 自动生成文档
  parameters: {
    layout: 'centered' // 将组件置于画布中心的可选参数
  },
  args: { onClick: fn() }
} satisfies Meta<typeof Button>
export default buttonMeta
type Story = StoryObj<typeof buttonMeta> // 定义组件的默认参数

export const DefaultButton: Story = {
  args: {
    btnType: 'default',
    children: 'default'
  }
}
DefaultButton.storyName = '默认按钮'

export const DisabledButton: Story = {
  args: {
    children: 'disabled',
    disabled: true
  }
}
DisabledButton.storyName = '禁用按钮'

export const SizeButton = () => (
  <Space>
    <Button size="lg"> large button </Button>
    <Button size="sm"> small button </Button>
  </Space>
)
SizeButton.storyName = '不同尺寸的按钮'

export const ThemeButton = () => (
  <Space>
    <Button btnType="primary"> primary button </Button>
    <Button btnType="danger"> danger button </Button>
    <Button btnType="link" href="https://baidu.com">
      link button
    </Button>
  </Space>
)

ThemeButton.storyName = '不同主题的按钮'
